package com.google.code.timetrail.backend;

import java.util.List;
import java.util.Random;

public class PlayerIllnessEvent extends Event{
    /**
	 * 
	 */
	private static final long serialVersionUID = 5030L;
	private Control gameControl;
    private List<Person> players;
    private Person randomSickPerson;
    private int removedPersonIndex;

    public PlayerIllnessEvent(Control gameControl){
        this.gameControl = gameControl;
        Random rand = new Random();
        players = gameControl.getMembers();
        
        removedPersonIndex = rand.nextInt(players.size());
        randomSickPerson = players.get(removedPersonIndex);
            if(!randomSickPerson.isDead() && !randomSickPerson.isSick() && rand.nextDouble() > randomSickPerson.getIllness()){
                super.formatMessage(randomSickPerson + " has gotten Sick in the time stream.");
            } else {
                super.messageText = getDummyText();
            }
        
    }
    
    public void Action(){
        randomSickPerson.sick();
    }
}
